#define _CRT_SECURE_NO_WARNINGS 1
//int main()
//{
//    int a, b;
//    cin >> a >> b;
//    //scanf("%d %d",&a,&b);
//    int ret = max(a, b);
//    int tmp = ret;
//    while (!(ret % a == 0 && ret % b == 0))
//    {
//        ret += tmp;
//    }
//    cout << ret << endl;
//    return 0;
//}

#include <iostream>
#include <vector>
#include <unordered_map>
#include <string>
using namespace std;
int dp[510][510];
int main()
{
    int m, n;
    cin >> m >> n;
    vector<string> nums;
    for (int i = 0; i < m; i++) cin >> nums[i];

    //vector<vector<int,int>> dp (m+1,vector<int>(n+1));
    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (nums[i - 1][j - 1] == 'l')dp[i][j] = 4;
            else if (nums[i - 1][j - 1] == 'o') dp[i][j] = 3;
            else if (nums[i - 1][j - 1] == 'v')dp[i][j] = 2;
            else if (nums[i - 1][j - 1] == 'e') dp[i][j] = 1;
            dp[i][j] += max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    cout << dp[m][n];
    return 0;
}